package com.java.demo.Service;

import com.java.demo.Dao.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

// 构造方法 注入
@Service
public class UserService2 {
    private UserRepository userRepository;

    @Autowired
    public UserService2(UserRepository userRepository) {
        this.userRepository = userRepository;
    }

    public void sayHi(){
        System.out.println("Do UserService2 sayHi");
        userRepository.add();
    }
}
